home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / sun3.md / vmSunAsm.s < prev   
Encoding:
Text File  |  1989-06-13  |  14.5 KB  |  539 lines

  1.  
  2. |* vmSun.s -
  3. |*
  4. |*    Subroutines to access Sun virtual memory mapping hardware.
  5. |*    All of the routines in here assume that source and destination
  6. |*    function codes are set to MMU space.
  7. |*
  8. |* Copyright (C) 1985 Regents of the University of California
  9. |* All rights reserved.
  10. |*
  11.  
  12. #include "vmSunConst.h"
  13. #include "machAsmDefs.h"
  14.  
  15.     .text
  16. #ifdef NOTDEF
  17.  
  18. |*
  19. |* ----------------------------------------------------------------------------
  20. |*
  21. |* VmMachReadPTE --
  22. |*
  23. |*         Map the given hardware pmeg into the kernel's address space and 
  24. |*    return the pte at the corresponding address.  There is a reserved
  25. |*    address in the kernel that is used to map this hardware pmeg.
  26. |*
  27. |*    VmMachPTE VmMachReadPTE(pmegNum, addr)
  28. |*        int        pmegNum;/* The pmeg to read the PTE for. */
  29. |*        Address    addr;    /* The virtual address to read the PTE for. */
  30. |*
  31. |* Results:
  32. |*     The value of the PTE.
  33. |*
  34. |* Side effects:
  35. |*     None.
  36. |*
  37. |* ----------------------------------------------------------------------------
  38. |*
  39.     .globl    _VmMachReadPTE
  40. _VmMachReadPTE:
  41. |* 
  42. |* Set the segment map entry.
  43. |*
  44.     movl    _vmMachPTESegAddr,a0    | Get access address
  45.     addl    #VMMACH_SEG_MAP_OFF,a0    | Bump to segment map offset
  46.     movl    sp@(4),d0        | Get segment map entry to write.
  47.     movsb    d0,a0@            | Write segment map entry
  48.  
  49. |*
  50. |* Get the page map entry.
  51. |*
  52.     movl    sp@(8),d0        | Get virtual address
  53.     andw    #VMMACH_PAGE_MAP_MASK,d0| Mask out low bits
  54.     addl    #VMMACH_PAGE_MAP_OFF,d0    | Add in page map offset.
  55.     movl    d0, a0
  56.     movsl    a0@,d0            | d0 <= page map entry
  57.  
  58.     rts                    | Return
  59.  
  60.  
  61. |*
  62. |* ----------------------------------------------------------------------------
  63. |*
  64. |* VmMachWritePTE --
  65. |*
  66. |*         Map the given hardware pmeg into the kernel's address space and 
  67. |*    write the pte at the corresponding address.  There is a reserved
  68. |*    address in the kernel that is used to map this hardware pmeg.
  69. |*
  70. |*    void VmMachWritePTE(pmegNum, addr, pte)
  71. |*        int           pmegNum;    /* The pmeg to write the PTE for. */
  72. |*        Address    addr;        /* The address to write the PTE for. */
  73. |*        VmMachPTE    pte;        /* The page table entry to write. */
  74. |*
  75. |* Results:
  76. |*     None.
  77. |*
  78. |* Side effects:
  79. |*     The hardware page table entry is set.
  80. |*
  81. |* ----------------------------------------------------------------------------
  82. |*
  83.     .globl    _VmMachWritePTE
  84. _VmMachWritePTE:
  85. |* 
  86. |* Set the segment map entry.
  87. |*
  88.     movl    _vmMachPTESegAddr,a0    | Get access address
  89.     addl    #VMMACH_SEG_MAP_OFF,a0    | Bump to segment map offset
  90.     movl    sp@(4),d0        | Get segment map entry to write.
  91.     movsb    d0,a0@            | Write segment map entry
  92.  
  93. |*
  94. |* Set the page map entry.
  95. |*
  96.     movl    sp@(8),d0        | Get virtual address into a register
  97.     andw    #VMMACH_PAGE_MAP_MASK,d0    | Mask out low bits
  98.     addl    #VMMACH_PAGE_MAP_OFF,d0    | Add in page map offset.
  99.     movl    d0, a0
  100.     movl    sp@(12),d0        | Get page map entry into a register
  101.     movsl    d0,a0@            | Write page map entry
  102.  
  103.     rts                    | Return
  104. #endif
  105. |*
  106. |* ----------------------------------------------------------------------------
  107. |*
  108. |* VmMachGetPageMap --
  109. |*
  110. |*         Return the page map entry for the given virtual address.
  111. |*    It is assumed that the user context register is set to the context
  112. |*    for which the page map entry is to retrieved.
  113. |*
  114. |*    int Vm_GetPageMap(virtualAddress)
  115. |*        Address virtualAddress;
  116. |*
  117. |* Results:
  118. |*     The contents of the hardware page map entry.
  119. |*
  120. |* Side effects:
  121. |*     None.
  122. |*
  123. |* ----------------------------------------------------------------------------
  124. |*
  125.     .globl    _VmMachGetPageMap
  126. _VmMachGetPageMap:
  127.     movl    sp@(4),d0        | Get virtual address into a register
  128.     andw    #VMMACH_PAGE_MAP_MASK,d0| Get relevant bits from address.
  129.     addl    #VMMACH_PAGE_MAP_OFF,d0    | Add in page map offset.
  130.     movl    d0, a0
  131.     movsl    a0@,d0            | Read page map entry
  132.  
  133.     rts                    | Return
  134. #ifdef notdef
  135. |*
  136. |* ----------------------------------------------------------------------------
  137. |*
  138. |* VmMachGetSegMap --
  139. |*
  140. |*         Return the segment map entry for the given virtual address.
  141. |*    It is assumed that the user context register is set to the context
  142. |*    for which the segment map entry is to retrieved.
  143. |*
  144. |*    int VmMachGetSegMap(virtualAddress)
  145. |*        Address virtualAddress;
  146. |*
  147. |* Results:
  148. |*     The contents of the segment map entry.
  149. |*
  150. |* Side effects:
  151. |*     None.
  152. |*
  153. |* ----------------------------------------------------------------------------
  154. |*
  155.     .globl    _VmMachGetSegMap
  156. _VmMachGetSegMap:
  157.     movl    sp@(4),d0        | Get virtual address in a register.
  158.     andw    #VMMACH_SEG_MAP_MASK,d0    | Get relevant bits.
  159.     addl    #VMMACH_SEG_MAP_OFF,d0    | Add in segment map offset
  160.     movl    d0, a0
  161.     clrl    d0            | Clear the return register.
  162.     movsb    a0@,d0            | Read segment map entry into return
  163.                     | register.
  164.  
  165.     rts                    | Return
  166. #endif
  167. |*
  168. |* ----------------------------------------------------------------------------
  169. |*
  170. |* VmMachSetPageMap --
  171. |*
  172. |*         Set the page map entry for the given virtual address to the pte valud 
  173. |*      given in pte.  It is assumed that the user context register is 
  174. |*    set to the context for which the page map entry is to be set.
  175. |*
  176. |*    void VmMachSetPageMap(virtualAddress, pte)
  177. |*        Address     virtualAddress;
  178. |*        VmMachPTE    pte;
  179. |*
  180. |* Results:
  181. |*     None.
  182. |*
  183. |* Side effects:
  184. |*     The hardware page map entry is set.
  185. |*
  186. |* ----------------------------------------------------------------------------
  187. |*
  188.     .globl    _VmMachSetPageMap
  189. _VmMachSetPageMap:
  190.     movl    sp@(4),d0        | Get virtual address into a register
  191.     andw    #VMMACH_PAGE_MAP_MASK,d0| Mask out low bits
  192.     addl    #VMMACH_PAGE_MAP_OFF,d0    | Add in page map offset.
  193.     movl    d0, a0
  194.     movl    sp@(8),d0        | Get page map entry into a register
  195.     movsl    d0,a0@            | Write page map entry
  196.  
  197.     rts                    | Return
  198. #ifdef NOTDEF
  199. |*
  200. |* ----------------------------------------------------------------------------
  201. |*
  202. |* VmMachPMEGZero --
  203. |*
  204. |*         Set all of the page table entries in the pmeg to 0.  There is a special
  205. |*    address in the kernel's address space (vmMachPTESegAddr) that is used to
  206. |*    map the pmeg in so that it can be zeroed.
  207. |*
  208. |*    void VmMachPMEGZero(pmeg)
  209. |*        int pmeg;
  210. |*
  211. |* Results:
  212. |*     None.
  213. |*
  214. |* Side effects:
  215. |*     The given pmeg is zeroed.
  216. |*
  217. |* ----------------------------------------------------------------------------
  218. |*
  219.  
  220.     .globl    _VmMachPMEGZero
  221. _VmMachPMEGZero:
  222. | Write segment map entry
  223.     movl    _vmMachPMEGSegAddr, d1    
  224.     movl    d1, a0            
  225.     addl    #VMMACH_SEG_MAP_OFF, a0    | a0 <= Segment map address    
  226.     movl    sp@(4),d0        | d0 <= PMEG num
  227.     movsb    d0,a0@            | Write PMEG num to segment map
  228.  
  229. | Now zero out all page table entries.
  230.  
  231.     movl    d1, a0            | a0 <= Starting address
  232.     addl    #VMMACH_PAGE_MAP_OFF, a0
  233.                     | d1 <= Ending address
  234.     addl    #(VMMACH_SEG_SIZE + VMMACH_PAGE_MAP_OFF), d1    
  235.     clrl    d0            | Clear out d0.
  236. 1$:
  237.     movsl    d0,a0@            | Write page map entry
  238.     addl    #VMMACH_PAGE_SIZE_INT, a0 | Go to next address.
  239.     cmpl    a0, d1            | See if have initialized all 
  240.     bgt        1$            |     ptes.
  241.  
  242.     rts                    | Return
  243.  
  244. |*
  245. |* ----------------------------------------------------------------------------
  246. |*
  247. |* VmMachReadAndZeroPMEG --
  248. |*
  249. |*    Read out all page table entries in the given pmeg and then set each to
  250. |*    zero. There is a special address in the kernel's address space 
  251. |*    (vmMachPTESegAddr) that is used to access the PMEG.
  252. |*
  253. |*    void VmMachPMEGZero(pmeg, pteArray)
  254. |*        int     pmeg;
  255. |*        VmMachPTE    pteArray[VMMACH_NUM_PAGES_PER_SEG];
  256. |*
  257. |* Results:
  258. |*      None.
  259. |*
  260. |* Side effects:
  261. |*     The given pmeg is zeroed and *pteArray is filled in with the contents
  262. |*    of the PMEG before it is zeroed.
  263. |*
  264. |* ----------------------------------------------------------------------------
  265. |*
  266.  
  267.     .globl    _VmMachReadAndZeroPMEG
  268. _VmMachReadAndZeroPMEG:
  269.     movl    _vmMachPMEGSegAddr, a0
  270.     addl    #VMMACH_SEG_MAP_OFF, a0        | a0 <= Segment map address    
  271.     movl    sp@(4),d0            | d0 <= PMEG num
  272.     movsb    d0,a0@                | Write PMEG num to segment map
  273.     movl    sp@(8), a1            | a1 <= pteArray
  274. | Subtract off seg map offset and add page map offset into a0.
  275.     addl    #(VMMACH_PAGE_MAP_OFF - VMMACH_SEG_MAP_OFF), a0
  276.     movl    #VMMACH_NUM_PAGES_PER_SEG_INT, d1    | d1 <= Pmegs per seg.
  277. 1$:
  278.     movsl    a0@, d0                | Read out the pte
  279.     movl    d0, a1@+            | a1 <= the pte
  280.     clrl    d0
  281.     movsl    d0, a0@                | Clear out the pte.
  282.     addl    #VMMACH_PAGE_SIZE_INT, a0    | Go to next address.
  283.     subql    #1, d1
  284.     bgt        1$            
  285.  
  286.     rts            
  287.  
  288.  
  289. |*
  290. |* ----------------------------------------------------------------------------
  291. |*
  292. |* VmMachSetSegMap --
  293. |*
  294. |*         Set the segment map entry for the given virtual address to the given 
  295. |*    value.  It is assumed that the user context register is set to the 
  296. |*    context for which the segment map entry is to be set.
  297. |*
  298. |*    void VmMachSetSegMap(virtualAddress, value)
  299. |*        Address    virtualAddress;
  300. |*        int        value;
  301. |*
  302. |* Results:
  303. |*     None.
  304. |*
  305. |* Side effects:
  306. |*     Hardware segment map entry for the current user context is set.
  307. |*
  308. |* ----------------------------------------------------------------------------
  309. |*
  310.     .globl    _VmMachSetSegMap
  311. _VmMachSetSegMap:
  312.     movl    sp@(4),d0        | Get access address
  313.     andw    #VMMACH_SEG_MAP_MASK,d0    | Mask out low bits
  314.     addl    #VMMACH_SEG_MAP_OFF,d0    | Bump to segment map offset
  315.     movl    d0, a0
  316.     movl    sp@(8),d0        | Get segment map entry to write in a 
  317.                         | register.
  318.     movsb    d0,a0@            | Write segment map entry
  319.  
  320.     rts                        | return
  321.  
  322. |*
  323. |* ----------------------------------------------------------------------------
  324. |*
  325. |* VmMachSegMapCopy --
  326. |*
  327. |*         Copy the software segment map entries into the hardware segment entries.
  328. |*    All segment table entries between address startAddr and address
  329. |*    endAddr are copied.  It is assumed that the user context register is 
  330. |*    set to the context for which the segment map entries are to be set.
  331. |*    
  332. |*    void VmMachSegMapCopy(tablePtr, startAddr, endAddr)
  333. |*        char *tablePtr;
  334. |*        int startAddr;
  335. |*        int endAddr;
  336. |*
  337. |* Results:
  338. |*     None.
  339. |*
  340. |* Side effects:
  341. |*     Hardware segment map entries for the current user context are set.
  342. |*
  343. |* ----------------------------------------------------------------------------
  344. |*
  345.     .globl _VmMachSegMapCopy
  346. _VmMachSegMapCopy:
  347.     movl    sp@(4),a0        | Get segment table address
  348.     movl    sp@(8),d1        | Get start address in a register.
  349.     andw    #VMMACH_SEG_MAP_MASK,d1    | Mask out low bits
  350.     addl    #VMMACH_SEG_MAP_OFF,d1    | Bump to segment map offset
  351.     movl    d1, a1
  352.     movl    sp@(12),d1        | Get end address in a register.
  353.     addl    #VMMACH_SEG_MAP_OFF, d1    | Add in offset.
  354. 1$:
  355.     movb    a0@,d0            | Get segment map entry to write.
  356.     movsb    d0,a1@            | Write segment map entry
  357.     addql    #1, a0            | Increment the address to copy from.
  358.     addl    #VMMACH_SEG_SIZE, a1    | Increment the address to copy to.
  359.     cmpl    a1, d1            | See if hit upper bound.  If not     
  360.     bgt        1$            | continue.
  361.  
  362.     rts
  363. /*
  364.  * Sun 2's require that the context offset be treated as a word and on Sun-3's
  365.  * it can't be.
  366.  */
  367.  
  368. #ifdef sun3
  369. #define    VMMACH_UC_OFF VMMACH_CONTEXT_OFF
  370. #define    VMMACH_KC_OFF VMMACH_CONTEXT_OFF
  371. #else
  372. #define    VMMACH_UC_OFF VMMACH_USER_CONTEXT_OFF:w
  373. #define    VMMACH_KC_OFF VMMACH_KERN_CONTEXT_OFF:w
  374. #endif
  375.  
  376. |*
  377. |* ----------------------------------------------------------------------------
  378. |*
  379. |* VmMachGetContextReg --
  380. |*
  381. |*         Return the value of the context register (on a Sun-2 the user context
  382. |*    register).
  383. |*
  384. |*    int VmMachGetContextReg()
  385. |*
  386. |* Results:
  387. |*     The value of context register.
  388. |*
  389. |* Side effects:
  390. |*     None.
  391. |*
  392. |* ----------------------------------------------------------------------------
  393. |*
  394.  
  395.     .globl    _VmMachGetContextReg
  396. _VmMachGetContextReg:
  397.                         | Move context reg into result 
  398.                             | register.
  399. #ifdef sun3
  400.     movsb    VMMACH_CONTEXT_OFF,d0         
  401. #else
  402.     movsb    VMMACH_USER_CONTEXT_OFF:w,d0
  403. #endif
  404.     andb    #VMMACH_CONTEXT_MASK,d0        | Clear high-order bits
  405.  
  406.     rts                        | Return
  407.  
  408. |*
  409. |* ----------------------------------------------------------------------------
  410. |*
  411. |* VmMachSetContextReg --
  412. |*
  413. |*         Set the user and kernel context registers to the given value.
  414. |*
  415. |*    void VmMachSetContext(value)
  416. |*        int value;        /* Value to set register to */
  417. |*
  418. |* Results:
  419. |*     None.
  420. |*
  421. |* Side effects:
  422. |*     None.
  423. |*
  424. |* ----------------------------------------------------------------------------
  425. |*
  426.     .globl    _VmMachSetContextReg
  427. _VmMachSetContextReg:
  428.  
  429.     movl    sp@(4),d0            | Get context value to set 
  430.                             | into a 
  431.                             | register
  432.  
  433.                         | Set context register(s).
  434. #ifdef sun3
  435.     movsb    d0, VMMACH_CONTEXT_OFF
  436. #else 
  437.     movsb    d0,VMMACH_USER_CONTEXT_OFF:w 
  438.     movsb    d0,VMMACH_KERN_CONTEXT_OFF:w
  439. #endif
  440.  
  441.     rts                        | Return
  442.  
  443. |*
  444. |* ----------------------------------------------------------------------------
  445. |*
  446. |* VmMachGetUserContext --
  447. |*
  448. |*         Return the value of the user context register.
  449. |*
  450. |*    int VmMachGetUserContext()
  451. |*
  452. |* Results:
  453. |*     The value of user context register.
  454. |*
  455. |* Side effects:
  456. |*     None.
  457. |*
  458. |* ----------------------------------------------------------------------------
  459. |*
  460.     .globl    _VmMachGetUserContext
  461. _VmMachGetUserContext:
  462.     movsb    VMMACH_UC_OFF,d0         | Get context reg value
  463.     andb    #VMMACH_CONTEXT_MASK,d0        | Clear high-order bits
  464.     rts                        | Return
  465.  
  466. |*
  467. |* ----------------------------------------------------------------------------
  468. |*
  469. |* VmMachGetKernelContext --
  470. |*
  471. |*         Return the value of the kernel context register.
  472. |*
  473. |*    int VmMachGetKernelContext()
  474. |*
  475. |* Results:
  476. |*     The value of kernel context register.
  477. |*
  478. |* Side effects:
  479. |*     None.
  480. |*
  481. |* ----------------------------------------------------------------------------
  482. |*
  483.     .globl    _VmMachGetKernelContext
  484. _VmMachGetKernelContext:
  485.     movsb    VMMACH_KC_OFF,d0         | Get context reg value.
  486.     andb    #VMMACH_CONTEXT_MASK,d0        | Clear high-order bits
  487.     rts
  488.  
  489. |*
  490. |* ----------------------------------------------------------------------------
  491. |*
  492. |* VmMachSetUserContext --
  493. |*
  494. |*         Set the user context register to the given value.
  495. |*
  496. |*    void VmMachSetUserContext(value)
  497. |*        int value;        /* Value to set register to */
  498. |*
  499. |* Results:
  500. |*     None.
  501. |*
  502. |* Side effects:
  503. |*     None.
  504. |*
  505. |* ----------------------------------------------------------------------------
  506. |*
  507.  
  508.     .globl    _VmMachSetUserContext
  509. _VmMachSetUserContext:
  510.     movl    sp@(4),d0            | Get context value to set.
  511.     movsb    d0,VMMACH_UC_OFF         | Set context register.
  512.     rts                        | Return
  513.  
  514. |*
  515. |* ----------------------------------------------------------------------------
  516. |*
  517. |* VmMachSetKernelContext --
  518. |*
  519. |*         Set the kernel context register to the given value.
  520. |*
  521. |*    void VmMachSetKernelContext(value)
  522. |*        int value;        /* Value to set register to */
  523. |*
  524. |* Results:
  525. |*     None.
  526. |*
  527. |* Side effects:
  528. |*     The supervisor context is set.
  529. |*
  530. |* ----------------------------------------------------------------------------
  531. |*
  532.  
  533.     .globl    _VmMachSetKernelContext
  534. _VmMachSetKernelContext:
  535.     movl    sp@(4),d0            | Get context value to set
  536.     movsb    d0,VMMACH_KC_OFF         | Set context register
  537.     rts                     | Return
  538. #endif
  539.